<?php

/**
 * informes actions.
 *
 * @package    sgcj
 * @subpackage informes
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 9301 2008-05-27 01:08:46Z dwhittle $
 */
class informesActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex()
  {
  }
  
  public function executeIndexinforme()
  {
  }
  
  public function executeInformeliquidacion()
  {
  }  
  
  public function executeReportecausa($request)
  {
  	$idacreedor = $request->getParameter('idacreedor');
  	$this->acreedor = AcreedorPeer::retrieveByPK($idacreedor);
  	$this->formFiltro = new FiltroEstadoCausaForm();
	

  	$criteria2 = new Criteria();
  	$criteria2->addJoin(ContratoPeer::ACREEDOR_ID, AcreedorPeer::ID);
  	$criteria2->addJoin(CausaPeer::CONTRATO_ID, ContratoPeer::ID);
  	$criteria2->add(ContratoPeer::ACREEDOR_ID,$this->acreedor->getId());
  	$criteria2->addJoin(CausaPeer::ID,EstadoCausaPeer::CAUSA_ID);
  	$criteria2->add(EstadoCausaPeer::ACTIVO,1);
  	
  	$filtro = false;
  	
	if($request->hasParameter('activa')){
		$filtro = true;
  		$lista[0] = 1;
  	}
  	
  	if($request->hasParameter('terminada')){
		$filtro = true;
  		$lista[1] = 2;
  	}
  	
  	if($request->hasParameter('castigada')){
		$filtro = true;
  		$lista[2] = 3;
  	}
  	
  	if($request->hasParameter('incobrable')){
		$filtro = true;
  		$lista[3] = 4;
  	}
  	
  	if($request->hasParameter('suspendida')){
		$filtro = true;
  		$lista[4] = 5;
  	}
  	
  	if($filtro){
  		$criteria2->add(EstadoCausaPeer::ESTADO_ID,$lista,Criteria::IN);
  		$this->causasList = CausaPeer::doSelect($criteria2);
  	}else{
  		$this->formFiltro->setDefault('activa',true);
  		$this->setTemplate('filtroestadocausa');
  	}
  }
   
  public function executeGenerareportecausa($request)
  {
  	$this->causa = CausaPeer::retrieveByPK($request->getParameter('id_causa'));
  	
  	$criteria = new Criteria();
  	$criteria->addJoin(PeriodoCausaPeer::CAUSA_ID,CausaPeer::ID);
  	$criteria->addJoin(DiligenciaPeer::PERIODO_CAUSA_ID,PeriodoCausaPeer::ID);
  	$criteria->add(CausaPeer::ID,$this->causa->getId());
  	$criteria->addDescendingOrderByColumn('fecha');
  	$criteria->setLimit(20);
  	
  	$this->diligenciaList = DiligenciaPeer::doSelect($criteria);
  }
  
  public function executeIndexcarta()
  {
  }

  public function executeRedactarcarta()
  {
  }
  
  public function executeShowcartaenviada()
  {
  }
  
  public function executeListformatocarta()
  {
  	$c = new Criteria();
  	$c->add(FormatoPeer::TIPO, '1');
  	$this->formatoList = FormatoPeer::doSelect($c);
  }
  
  public function executeShowformato($request)
  {
  	$this->formato = FormatoPeer::retrieveByPk($request->getParameter('id'));
    $this->forward404Unless($this->formato);
  }
  
  public function executeIndexescrito()
  {
  }
  
  public function executeRedactarescrito()
  {
  }
  
  public function executeShowescritoenviado()
  {
  }
  
  public function executeListformatoescrito()
  {
  	$c = new Criteria();
  	$c->add(FormatoPeer::TIPO, '0');
  	$this->formatoList = FormatoPeer::doSelect($c);
  }  
}
